public class Solution1716 {
    public int totalMoney(int n) {
        int m=n/7;
        return 28*m+7*(m-1)*m/2+(n+1-5*m)*(n-7*m)/2;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1716().totalMoney(20));
    }
}
